package com.toolsder.demo.spring.security.jwt.repository;

import com.toolsder.demo.spring.security.jwt.entity.database.Resources;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

/**
 * created by 猴子请来的逗比 On 2020/8/11
 *
 * @author by 猴子请来的逗比
 */
public interface ResourcesRepository extends JpaRepository<Resources, Long>, JpaSpecificationExecutor<Resources> {

    Resources findByResourcesUrl(String resourcesUrl);

    boolean existsByResourcesUrl(String url);

    @Modifying
    @Query("UPDATE Resources SET resourcesName=:resourcesName WHERE id=:id")
    void updateName(@Param("id") Long id, @Param("resourcesName") String name);
}
